"""
PyMicroFlow 序列化器包
提供多种高性能序列化实现
"""

from .protobuf import ProtobufSerializer
from .msgpack import MessagePackSerializer
from .json import OptimizedJsonSerializer
from .adapter import SerializationAdapter

__all__ = [
    'ProtobufSerializer',
    'MessagePackSerializer',
    'OptimizedJsonSerializer',
    'SerializationAdapter'
]

# 版本信息
__version__ = '1.0.0'

# 默认序列化器配置
DEFAULT_SERIALIZERS = {
    'protobuf': ProtobufSerializer,
    'msgpack': MessagePackSerializer,
    'json': OptimizedJsonSerializer,
}


def get_serializer(format_name: str, **kwargs):
    """
    获取指定格式的序列化器实例

    Args:
        format_name: 序列化格式名称
        **kwargs: 序列化器初始化参数

    Returns:
        序列化器实例

    Raises:
        ValueError: 不支持的序列化格式
    """
    if format_name not in DEFAULT_SERIALIZERS:
        raise ValueError(f"不支持的序列化格式: {format_name}")

    serializer_class = DEFAULT_SERIALIZERS[format_name]
    return serializer_class(**kwargs)